package com.grass.cropTradingCenter.controller.shop;

import com.grass.cropTradingCenter.common.PageResult;
import com.grass.cropTradingCenter.common.Result;
import com.grass.cropTradingCenter.pojo.entity.Goods;
import com.grass.cropTradingCenter.pojo.entity.UserOrder;
import com.grass.cropTradingCenter.pojo.vo.shop.GoodsListVo;
import com.grass.cropTradingCenter.pojo.vo.shop.OrderListVo;
import com.grass.cropTradingCenter.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/shop/goods")
@Api(tags = "商家 -- 农产品接口")
public class GoodsController {


    @Autowired
    private GoodsService goodsService;


    @PostMapping("/goodsList")
    @ApiOperation("农产品列表")
    public PageResult<Goods> goodsList(@RequestBody GoodsListVo vo) {
        return goodsService.goodsList(vo);
    }

    @PostMapping("/addOrUpdateGoods")
    @ApiOperation("添加或修改农产品")
    public Result addOrUpdateGoods(@RequestBody Goods vo) {
        goodsService.addOrUpdateGoods(vo);
        return Result.success();
    }

    @PostMapping("/orderList")
    @ApiOperation("订单列表")
    public PageResult<UserOrder> orderList(@RequestBody OrderListVo vo) {
        return goodsService.orderList(vo);
    }

    @PostMapping("/confirmFH/{id}")
    @ApiOperation("确认发货")
    public Result confirmFH(@PathVariable("id") Integer id) {
        goodsService.confirmFH(id);
        return Result.success();
    }

    @PostMapping("/confirmTK/{id}")
    @ApiOperation("确认退款")
    public Result confirmTK(@PathVariable("id") Integer id) {
        goodsService.confirmTK(id);
        return Result.success();
    }


}
